#!/usr/bin/env python
'''Takes filtered ical output from Facebook application www.fbCal.com
of the following form:

19310406
Ram Dass
18420111
William James
19150106
Alan Watts
17230616
Adam Smith

and reformats it for unix calendar(1) in this form:

04/06/1931\tRam Dass
01/11/1842\tWilliam James
01/06/1915\tAlan Watts
06/16/1723\tAdam Smith


'''


__RCS__ = '$Id$'
__version__ = '$Revision:$'
__initialdate__ = 'October 2007'
__license__ = '''Copyright (c) 2007, Darren Paul Griffith, All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
  this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.'''

__author__ = 'Darren Paul Griffith <http://madphilosopher.ca/>'


import sys

# read in all lines
list = []
for line in sys.stdin:
    list.append(line.strip())

# take pairs of lines to create (date,name) tuples
for i in range(0,len(list),2):
    date, name = list[i], list[i+1]
    year, month, day = date[0:4], date[4:6], date[6:8]

    # create formatted output
    formatted_date = month + '/' + day + '/' + year 
    print "%s\t%s" % (formatted_date, name)

